/*
	xmlOutputWriter.hxx
	--------------------
	
	Author: Olivier Sputael
	
	This file is the header of the class that will generate a xml output file.
*/

#include <string.h>
#include <stdlib.h>
#include <sl/dslinter.hxx>
#include <sl/sloperdef.hxx>
#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>

class XmlOutputWriter {
public: 
	XmlOutputWriter	(char*);
	~XmlOutputWriter ();
	
	void endWriting ();
	
	xmlChar* ConvertInput(char*, const char*);
	char* getOpcodeText (int);
	char* getSimpleTypeText (int);
	char* getKindOfTypeText (int);
	char* intToCharPtr (int);
	char* longToCharPtr (long);
	char* unvShortToCharPtr (UNV_SHORT*);
	char* unvLongToCharPtr (UNV_LONG*);
	char* charToCharPtr (char);
	
	void generate_xml_debug (char*);
	
	void generate_xml_tag_end ();
	void generate_xml_header (char*, int, char*, UNV_SHORT&, UNV_SHORT&, 
								UNV_SHORT&, UNV_SHORT&, UNV_LONG&, 
								UNV_LONG&, UNV_LONG&, UNV_LONG&);
	void generate_xml_common_type_header (char*, int, UNV_LONG&);
	void generate_xml_channel (int, UNV_SHORT&, UNV_SHORT&, char*, char*, 
								UNV_LONG&, char*, char*, char*);
	void generate_xml_program_begin (char*, int, char*);
	void generate_xml_type_begin (char*);
	void generate_xml_struct_field (int, char*, UNV_LONG&, UNV_LONG&, char*);
	void generate_xml_type_simple_type (int);
	void generate_xml_type_struct (UNV_SHORT&);
	void generate_xml_type_array (UNV_LONG&, UNV_LONG&, UNV_LONG&);
	void generate_xml_type_list (UNV_LONG&, UNV_LONG&);
	void generate_xml_type_pointer_or_derived (UNV_LONG&);
	void generate_xml_variables (int, char*, DSL_TYPE_ID&, UNV_DIC_VAR_ID&, 
									UNV_DIC_VAR_ID&, UNV_LONG&, UNV_SHORT&, 
									UNV_LONG&, UNV_SHORT&, int, int, char*, 
									char*);
	void generate_xml_method_begin (int, UNV_METHOD_ID&, DSL_TYPE_ID&, char*, 
									char*, UNV_SHORT&);
	void generate_xml_start_node (int, char*, long, UNV_SHORT&);
	void generate_xml_instructions (int, char*, UNV_SHORT&, UNV_SHORT&, 
									UNV_SHORT&, UNV_SHORT&, UNV_LONG&, 
									UNV_LONG&, UNV_LONG&, UNV_LONG&, int);
	void generate_xml_instructions_method (int);
	void generate_xml_node (long, char*);
	void generate_xml_trigger (int, char*);
	void generate_xml_case_statement_begin (long);
	void generate_xml_case_statement_elems (long, short, short);
	void generate_xml_method_call(UNV_LONG&, int, long);
	void generate_xml_statements_plugin_name(char*);
	void generate_xml_operation (int, char*, UNV_SHORT&, UNV_SHORT&, 
									UNV_SHORT&, UNV_SHORT&, UNV_LONG&, 
									UNV_LONG&, UNV_LONG&, UNV_LONG&, int);
	void generate_xml_operation_operator (int);
	void generate_xml_operation_select_stack (UNV_LONG&);
	void generate_xml_operation_function_call (char*, int, UNV_SHORT&);
	void generate_xml_operation_select_struct (UNV_LONG&);
	void generate_xml_operation_value_constant (UNV_SHORT&, char*);
	void generate_xml_operation_volatile_var (UNV_LONG&);
	void generate_xml_sequence (int, char*, char*, int);
	void generate_xml_statements (int, char*, UNV_CFG_ID&, int, char*);
	void generate_xml_statements_self (UNV_LONG&);
private:
	xmlTextWriterPtr writer;
};
